<template>
    <div class="chat-container">
      <div v-for="(message, index) in messages" :key="index" :class="message.type + '-message'">
        <div v-if="message.type === 'user'" class="user-message right">{{ message.text }}</div>
        <div v-else class="bot-message">{{ message.text }}</div>
      </div>
      <div class="input-container">
        <input type="text" v-model="userInput" @keyup.enter="sendMessage" placeholder="Type your message...">
        <button @click="sendMessage">Send</button>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        userInput: '',
        messages: []
      };
    },
    methods: {
      sendMessage() {
        if (this.userInput.trim() !== '') {
          this.messages.push({ text: this.userInput, type: 'user' });
          this.botResponse(this.userInput);
          this.userInput = '';
        }
      },
      botResponse(userInput) {
        // Simple logic for bot response, you can replace it with your AI model integration
        const botResponse = 'Sorry, I am just a simple bot. I cannot respond intelligently yet.';
        this.messages.push({ text: botResponse, type: 'bot' });
      }
    }
  };
  </script>
  
  <style scoped>
  .chat-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
  }
  
  .user-message {
    background-color: #007bff;
    color: white;
    padding: 10px;
    border-radius: 5px;
    max-width: 70%;
  }
  
  .bot-message {
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    max-width: 70%;
  }
  
  .right {
    margin-left: auto;
    text-align: right;
  }
  
  .input-container {
    display: flex;
    margin-top: 20px;
  }
  
  input[type="text"] {
    flex: 1;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
  }
  
  button {
    padding: 10px 20px;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
  }
  
  button:hover {
    background-color: #0056b3;
  }
  </style>
  